﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net.Sockets;

namespace ggprot
{
    public class GGHeader
    {
        private int type;
        private int length;

        public int Length
        {
            get { return length; }
            set { length = value; }
        }

        public int Type
        {
            get { return type; }
            set { type = value; }
        }

        public virtual void Write(NetworkStream stream)
        {
            BinaryWriter writer = new BinaryWriter(stream);

            writer.Write(type);
            writer.Write(length);

            writer.Flush();
        }

        public virtual void Read(NetworkStream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            type = reader.ReadInt32();
            length = reader.ReadInt32();
        }

        public GGHeader(Packets type, int length)
        {
            this.type = (int)type;
            this.length = length;
        }

        public GGHeader() { }
    }
}
